<include file="Public/header" /> 

<!--主窗体-->
<div class="container app">
	<!--左侧菜单-->
	<include file="Public/sidebar" /> 
	<!--左侧菜单//-->
	
	<!-- mainCon -->
	<div id="mainCon" class="mainCon">
		<h4>用户列表</h4>
		<div class="bk10"></div>
		<div>
			<form class="form-inline">
				<div class="form-group form-group-sm">
					<label for="username">用户名：</label>
					<input type="text" class="form-control" id="username" name="username" placeholder="用户名" value="<{$username}>">
				</div>
				<div class="form-group form-group-sm">
					<label for="nickname">真实姓名：</label>
					<input type="text" class="form-control" id="nickname" name="nickname" placeholder="真实姓名" value="<{$nickname}>">
				</div>
				<div class="form-group form-group-sm">
					<label for="email">电子邮件：</label>
					<input type="text" class="form-control" id="email" name="email" placeholder="电子邮件" value="<{$email}>">
				</div>
				
				<div class="bk10"></div>
				
				<div class="form-group form-group-sm">
					<label for="start_time">注册时间：</label>
					<input type="text" class="form-control laydate-icon" id="start_time" name="start_time" onclick="laydate({istime:true, format:'YYYY-MM-DD hh:mm:ss'})" value="<{$start_time?($start_time|date='Y-m-d H:i:s',###):''}>">
					<span>-</span>
					<input type="text" class="form-control laydate-icon" id="end_time" name="end_time" onclick="laydate({istime:true, format:'YYYY-MM-DD hh:mm:ss'})" value="<{$end_time?($end_time|date='Y-m-d H:i:s',###):''}>">
				</div>

				<div class="form-group form-group-sm">
					<label for="status">状态：</label>
					<select id="status" name="status" class="form-control">
						<option value="All" <if condition="$status eq 'All'">selected</if> >全部</option>
						<option value="0" <if condition="$status === 0">selected</if> >锁定</option>
						<option value="1" <if condition="$status === 1">selected</if> >正常</option>
					</select>
				</div>
				<button type="submit" class="btn btn-default btn-sm">查询用户</button>
			</form>
		</div>
		<div class="bk10"></div>
		<table class="table table-bordered table-hover">
			<tr>
				<th>编号</th>
				<th>用户名</th>
				<th>真实姓名</th>
				<th>电子邮件</th>
				<th>注册时间</th>
				<th>上次登录</th>
				<th>角色</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
			
			<empty name="list">
				<tr><td colspan="8" style="text-align:center;color:#999">～暂无数据～</td></tr>
			<else /> 
			
				<foreach name="list" item="vo">
				
					<tr>
						<td><{$vo['id']}></td>
						<td><{$vo['username']}></td>
						<td><{$vo['nickname']}></td>
						<td><{$vo['email']}></td>
						<td><{$vo['createtime']|date="Y-m-d H:i",###}></td>
						<td>
						<if condition="$vo['lasttime'] neq 0">
							<{$vo['lasttime']|date="Y-m-d H:i:s",###}>
						<else />
							从未登录
						</if>
						</td>
						<td><{$vo['name']}></td>
						<td>
							<if condition="$vo['status'] eq 1">
								<span style="color:#66CC33">正常</span>				
							<else />
								<span style="color:#FFA530">锁定</span>
							</if>
						</td>
						<td>
							<if condition="session('uid') neq $vo['id']">
								<if condition="$vo['status'] eq 1">
									<a href="javascript:void(0)" class="userLock" data-status="0" data-id="<{$vo['id']}>">锁定</a>
								<else />
									<a href="javascript:void(0)" class="userLock" data-status="1" data-id="<{$vo['id']}>">启用</a>
								</if>
							</if>
							<a href="<{:U('Admin/Admin/userEdit',array('uid'=>$vo['id'],'k'=>5,'sk'=>1))}>">编辑</a>
							<if condition="session('uid') neq $vo['id']">
								<a href="javascript:void(0)" class="delAct" data-id="<{$vo['id']}>">删除</a>
							</if>
						</td>
					</tr>
				</foreach>
			
			</empty> 
			
			
		</table>
		
		<div class="pagebar">
			<{$pager}>
		</div>
		
	</div>
	<!-- mainCon// -->
	
</div>
<!--主窗体//-->

<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
$(function(){
	$(".userLock").click(function(){
		var status = $(this).attr("data-status");
		var uid = $(this).attr("data-id");
		if(status == 0){
			var msg = "您是否确定锁定该用户？锁定后该用户将无法登录管理后台。";	
		}else{
			var msg = "您是否确定启用该用户？启用后该用户将可以登录管理后台。";	
		}
		layer.confirm(msg, {icon: 3, title:'提示'}, function(index){
			$.post("<{:U('Admin/Admin/userLock')}>",{"status":status,"uid":uid},function(r){
				if(r.error == 1){
					layer.close(index);
					layer.alert(r.errmsg,{icon: 2});
				}else{
					window.location.reload();
				}
			});
		});
		return false;
	});
	
	
	$(".delAct").click(function(){
		var that = this;
		layer.confirm('您是否确认删除该记录？删除后不可恢复！', {icon: 3, title:'提示'}, function(index){
			var itemid = $(that).attr("data-id");
			$.post("<{:U('Admin/Admin/userDel')}>",{id:itemid},function(r){
				if(r.error == 1){
					layer.close(index);
					layer.alert(r.errmsg,{icon: 2});
				}else{
					window.location.reload();
				}
			});
		    //layer.close(index);
		});
		return false;
	});
});
</script>

<include file="Public/footer" /> 